Skip to content

Route all arbitrary verifier MSM terms through one storage - #186

Open
ValarDragon wants to merge 1 commit into
mainfrom
agent/msm-single-storage
Open

Route all arbitrary verifier MSM terms through one storage#186
ValarDragon wants to merge 1 commit into
mainfrom
agent/msm-single-storage

Conversation

@ValarDragon

@ValarDragon ValarDragon commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #182, now rebased onto main.

Summary

Deletes the incremental BTreeMap from the verifier MSM:
append_term, add_msm, and add_msm_batch now feed the same contiguous
term buffer. The shared canonicalize_other routine performs the stable
x-coordinate sort and orientation-aware coalescing before the selected MSM
backend consumes those terms.

One storage, one truth:

  • eval, the plain multiexp fallback, and the fingerprint export cannot
    disagree about which representation is authoritative;
  • scale, add_msm, and add_msm_batch each touch one arbitrary-term
    container;
  • the former empty-batch special case in multiexp is gone.

Semantics are unchanged: coalescing algebra is identical (same orientation
rule and same first-encountered orientation after the stable sort), zero-scalar
entries are retained exactly as the map retained them, and identity filtering
in append_term is untouched.

Rebase integration

Current main added the prepared fixed-base zero-check after this PR was
opened. The rebased prepared path canonicalizes the shared buffer in place
before converting arbitrary terms into its extra input. If the prepared
route declines because the extras exceed its bound, the plain multiexp
fallback re-canonicalizes that already-canonical buffer; this is idempotent.

The existing differential tests cover borrowed versus owned aggregation,
tree-shaped batch reduction, scaling, exact cancellation, opposite point
orientations, prepared versus unprepared evaluation, and fingerprint parity.

Benchmarks

Apple M4, 4 interleaved rounds, min of medians, --features batch,multicore,
baseline = #182 head:

bench base this PR ratio
plonk-verifier-orchard-shaped/actions/1 1.053 ms 1.056 ms 1.003
actions/2 1.103 ms 1.104 ms 1.001
actions/16 1.834 ms 1.842 ms 1.005
actions/64 4.344 ms 4.330 ms 0.997
msm/k/8..15 sweep 0.989–1.009 (noise)

Single-proof verification is neutral: sorting about 60 terms once costs what
about 60 map probes did. The change is a simplification, not an optimization.

Security and correctness review

No findings. Transcript-derived commitment points remain validated
CurveAffine values, identity filtering is unchanged, and orientation
coalescing preserves [s](-P) = [-s]P. The storage change does not alter the
Fiat–Shamir transcript, verifier equation, subgroup handling, or acceptance
condition.

Validation

  • cargo test -p zakura-halo2-proofs --features orbits,unstable-verifier-fingerprint
    (116 unit tests, 5 integration tests, and doc tests)
  • cargo test -p zakura-halo2-proofs --no-default-features --features batch --lib poly::commitment::msm::tests
    (4 focused MSM tests)
  • cargo check --release -p zakura-halo2-proofs --no-default-features --features batch
  • cargo fmt --all --check
  • ./scripts/changelog.py check

No public or pub(crate) API surface changes.

Base automatically changed from agent/flat-msm-aggregation to main August 25, 2026 01:05
@ValarDragon
ValarDragon force-pushed the agent/msm-single-storage branch from 9ea9091 to e2fe378 Compare August 25, 2026 09:12
Delete the incremental BTreeMap: append_term and add_msm now push into
the same contiguous term buffer the batch verifier uses, and the single
canonicalization in multiexp (sort by x, coalesce orientations) is the
one place duplicate bases merge. One storage, one truth: eval and the
fingerprint export cannot disagree about which representation is
authoritative, scale touches one container, and the empty-buffer branch
disappears. A single proof's ~60 terms sort in microseconds, replacing
a BTreeMap probe per appended term.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ValarDragon
ValarDragon force-pushed the agent/msm-single-storage branch from e2fe378 to 40e7193 Compare August 30, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant